package com.uinnova.product.eam.init.schedule;

import com.binary.framework.bean.annotation.Comment;
import com.uinnova.product.eam.init.schedule.job.CmdbSysSyncJob;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Comment("CMDB新建系统流程调用定时任务配置")
@Configuration
public class CmdbSysSyncConfiguration {

    @Value("${guotou.cmdb.sys.sync.cron:0 0/10 * * * ?}")
    private String cmdbSysSyncCron;

    @Bean
    public JobDetail cmdbSysSyncJob() {
        return JobBuilder.newJob(CmdbSysSyncJob.class).withIdentity("CmdbSysSyncJob").storeDurably().build();
    }

    @Bean
    public Trigger cmdbSysSyncJobTrigger(JobDetail cmdbSysSyncJob) {
        CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(cmdbSysSyncCron);
        return TriggerBuilder.newTrigger().forJob(cmdbSysSyncJob)
                .withIdentity("CmdbSysSyncJob").withSchedule(scheduleBuilder).build();
    }

}